class Solution:
    def countAnagrams(self, s: str) -> int:
        words = s.split()
        result = 1
        MOD = 1000000007
        for word in words:
            charCount = {}
            for c in word:
                charCount[c] = charCount.get(c, 0) + 1
            perm = math.factorial(len(word))
            for _, count in charCount.items():
                perm //= math.factorial(count)
            result *= perm
            result %= MOD
        return result
